<?php
if(isset($_GET['id']))
{
// if id is set then get the file with the id from database

		$user="root";
		$password="";
		$database="whitehouse";
		mysql_connect(localhost,$user,$password);
		@mysql_select_db($database) or die( "Unable to select database");


$id    = $_GET['id'];
$query = "SELECT octet_length(content) a, content, start, end, unit_name ".
         "FROM inactive WHERE id = $id";

$result = mysql_query($query) or die('Error, query failed');
$row= mysql_fetch_array($result);
$content = $row['content'];
$size = $row['a'];
$name = $row['unit_name']."_".$row['start']."_".$row['end'].".txt";

header("Content-length: $size+1");
header("Content-type: text/plain");
header("Content-Disposition: attachment; filename=$name");
echo $content;


exit;
}

?>